//
//  XYTTabViewController.m
//  XYTPayOrderSystem
//
//  Created by wupeng on 2017/9/4.
//  Copyright © 2017年 wupeng. All rights reserved.
//

#import "XYTTabViewController.h"
#import "XYTBaseNavigationViewController.h"
#import "XYTHomePgaeViewController.h"
#import "XYTOrderEnteringViewController.h"
#import "XYTUserEnteringViewController.h"
#import "XYTPersonCenterViewController.h"
#import "XYTLoginRegisterViewController.h"

@interface XYTTabViewController ()

@end

@implementation XYTTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.backgroundColor=[UIColor whiteColor];
    
    [self loadTabViewControllers];
    
}
- (void)loadTabViewControllers{
    NSArray *vcClasssNames = @[@"XYTHomePgaeViewController",@"XYTOrderEnteringViewController",@"XYTUserEnteringViewController",@"XYTPersonCenterViewController"];
    NSArray *selectedImages = @[@"D3B43657-7E21-4F33-99EA-3A60A2913090",@"9D5BAD52-3BB8-4C94-B034-DE2B78426655",@"E901CA1C-2D0A-4423-830D-B0B009F25CAE",@"FFA78C67-6D97-4631-BECA-988674D33267"];
    NSArray *normalimages = @[@"09543DF7-4DAE-43A5-8753-36B501BE980C",@"F29A4C53-3A4E-4233-8B0E-2D2022B0B514",@"5616E3BB-10D7-41CD-BF36-73596DB6A52E",@"EA457135-FB13-4A53-B37D-5504C923B5A9"];
    NSArray *titles = @[@"首页",@"订单录入",@"用户录入",@"我的"];
    
    NSMutableArray *viewControllers = [NSMutableArray array];
    
    int i = 0;
    for (NSString *name in vcClasssNames) {
        //创建导航视图控制器
        XYTBaseNavigationViewController *nc = [self navigationWithClass:NSClassFromString(name)];
        
        UIImage *normalImage = [UIImage imageNamed:normalimages[i]];
        UIImage *oNormalImage = [normalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UIImage *selectedImage = [UIImage imageNamed:selectedImages[i]];
        UIImage *oSelectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:titles[i] image:oNormalImage selectedImage:oSelectedImage];
        
        nc.tabBarItem = item;
        
        [viewControllers addObject:nc];
        
        i++;
    }
    
    self.viewControllers = viewControllers;
}

- (XYTBaseNavigationViewController *)navigationWithClass:(Class)vcClass
{
    UIViewController *vc= [[vcClass alloc]init];
    XYTBaseNavigationViewController *basenc = [[XYTBaseNavigationViewController alloc] initWithRootViewController:vc];
    
    return basenc;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
